home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-05
/
pcprl11.zip
/
LCP.DOC
< prev
next >
Wrap
Text File
|
1991-12-01
|
14KB
|
481 lines
Linda Conversion Program
Parallel Computer Solutions, Inc.
November 30, 1991
Copyright 1991 Parallel Computer Solutions. All Rights Reserved
The terms and conditions governing the sale of Parallel Computer
Solutions hardware products and the licensing of Parallel Computer
Solutions software consist solely of those set forth in the written
contracts between Parallel Computer Solutions and its customers.
No representation or other affirmation of facts contained in this
publication, including but not limited to statements regarding
capacity, response time, suitability for use or performance of
products described herein shall be deemed to be a warranty by
Parallel Computer Solutions for any purpose or give rise to any
liability by Parallel Computer Solutions whatever.
No part of this document may be copied or reproduced in any form or
by any means without the prior written consent of Parallel Computer
Solutions. Information is subject to change without notice.
Printed in the United States of America.
Parallel Lan System is a copyright of Parallel Computer Solutions.
Linda is a copyright of Scientific Computing Associates Inc. Turbo
Pascal is a copyright of Borland International Inc.
Introduction
The Parallel Lan System requires the use of the
coordination language PCS-Linda is order to execute parallel
programs. The language itself is beyond these instructions for the
conversion program. Those wishing to get a feel for the Linda
language used in the Parallel Lan System are directed to the manual
A Guide to Parallel Programming Using PCS-Linda and the Parallel
Lan System published by Parallel Computer Solutions.
Purpose
The Linda Conversion Program converts a program written
using Turbo Pascal and PCS-Linda into pure Turbo Pascal.
Thus allowing the Turbo compiler to compile the program. This
instruction document will describe the operation, limitations, and
specifications of the conversion program.
Operation
When started, the Linda Conversion Program ( LCP ) will
blank the screen and produce the following display
Parallel Lan System
Linda Conversion Program
Enter name of file to be processed ->
LCP is waiting for the filename of the program to be
converted. This file must end with the extension .PLS. If the file
is not found by LCP the message
File not found..
will be displayed and the program will exit. If the file does
exist, check your spelling and run the program again. It is not
necessary to include the extension when entering the name of the
file. It however, can be included if desired.
Once LCP has found the file, it will inform you that its
output will be named with an extension of .PAS. The same initial
name will be used.
When LCP is finished with your program, it will display the
message
Finished!
Parallel Lan System is a copyright of Parallel Computer Solutions.
Linda is a copyright of Scientific Computing Associates Inc.
The new file can be compiled with Turbo Pascal and executed
on the Parallel Lan System.
Alternatively, the file to be converted can be included in
the command line. Thus to convert the file test.pls we would type
linda test
Limitations
The Linda Conversion Program will not produce any error
messages. This has been left up to the Turbo Pascal compiler. In
order to make some sense of the resulting pascal code, the
following examples are given. The three examples will illustrate
the different code that the LCP will produce. The first example
shows code generated for the in () and rd () instructions. The
second example shows the eval () instruction. The third example
will show the rdp () and inp () instructions. A short
explanatation will be given about the code for the out ()
instruction.
IN (); and RD ();
The LCP, when given the Linda command
in ( 'stuff', a, &v, 1, 2 );
will produce the following Turbo Pascal code
{ in ( 'stuff', a, &v, 1, 2 ); }
begin
make_tuple( 5,'s','t','u','f','f',' ',' ',' ',' ',' ',' ',' ',' ','
',' ',' ', @a, sizeof ( a ), no, @v sizeof ( v ), yes,
@anint[3], sizeof ( anint[3] ), yes,
@anint[4], sizeof ( anint[4] ), yes,
nil, 0, null,
nil, 0, null
);
anint[3] := 1;
anint[4] := 2;
send_tuple ( _in );
get_tuple ( pkt, plen );
convert_to_tuple_made ( pkt, a_tuple );
end;
An Explanation
Because this is the code that the Turbo Pascal Compiler
will have to compile, we will go over what the statements do in the
event that an error occurs in the middle of the code.
The first eight lines appear to be a jumble of code but it
is a single procedure call which assembles a tuple based on the information
given to the procedure. A procedure call was used to decrease the
amount of code produced by the Linda Conversion Program.
make_tuple( 5,'s','t','u','f','f',' ',' ',' ',' ',' ',' ',' ',' ','
',' ',' ', @a, sizeof ( a ), no, @v, sizeof ( v ), yes,
@anint[3], sizeof ( anint[3] ), yes,
@anint[4], sizeof ( anint[4] ), yes,
nil, 0, null,
nil, 0, null
);
Several things can happen when the Turbo Pascal Compiler begins
to compile this code. The original command was
in ( 'stuff', a, &v, 1, 2 );
which tells use that we must have two variables a and v declared in
the VAR section. If an error occurs at either the @a/@v or the
sizeof(a)/sizeof(v), check to make sure that you have declared the
two variables. Remember, if this tuple command is in the
procedure to be sent to a worker, the variables must be declared
local in the procedure and not global.
It is very important not to declare the variable array
anint. This is a system array that is used during tuple
transmission and is of no concern to the developer. Because we only
used four of the six elements in the variable, the nil, 0, null
entries will instruct the make_tuple procedure to handle these
empty elements.
After the appropriate operation have been performed in the
tuple definition, the system will assign any actual numbers in the
tuple to the system variable arrays. We had two such actuals; 1
and 2.
anint[4] := 2;
anint[3] := 1;
The next three instructions do the actual transmission and
reception of tuples. First we have to send the tuple request to
the master
send_tuple ( _in );
This instruction will use a system user-defined set
element; _in. This instructs the sending routine to tell the master
that this tuple is to be treated as an IN tuple. If this instruction
was a RD, then we would use the system user-defined set element RD
instead of _in.
Because the tuple is an IN tuple, we are guaranteed a tuple
in return ( at least we hope ). The procedure get_tuple will
receive a tuple and put it into a special buffer.
get_tuple ( pkt, plen );
This buffer doesn't really contain a tuple. It contains a
long sequence of bytes which must be translated and formed into the
tuple we sent to the match for the match. The
convert_to_tuple_made procedure performs this conversion.
convert_to_tuple_made ( pkt );
If we look at the original IN instruction, we see that only
the a variable will be given a value from the new tuple we
received. The actuals 1, 2, and variable v were used as matching
elements only.
All of the procedure and most of the variable are system
related. They have been coded in the work and both units that have
to be USESed into the program.
EVAL ();
The eval instruction that we are going to decode is
eval ( 'work', &adder );
This instruction becomes
{ eval ( 'work', &adder ); }
begin
make_tuple(4,'w','o','r','k',' ',' ',' ',' ',' ',' ',' ',' ',' ','
',' ', ' ', @segofs, sizeof ( segofs ), yes, @adder , sizeof (
adder ), data,
nil, 0, null,
nil, 0, null,
nil, 0, null,
nil, 0, null
);
find_procedure_length ( @adder, integer(a_tuple^.elements[2].size
)); send_tuple ( eval ); end;
after the Linda Conversion Program does its work. Everything is
the same except the statements after the assignment of the name of
the tuple. The make_tuple statement includes as additional element
that the original PCS-Linda instruction did not contain. The
variable segofs contains information about the developer the
program is executing on. It must be included with the eval tuple
sent to the master but the software engineer doesn't need to know
about it so the Linda Conversion Program inserts it for us.
After our tuple has been made, we have to fill in one of
the elements positions. Notice in the statements for the
make_tuple procedure call, the length of the procedure that is to
be sent to the master is 0. That would be of little use so a call
must be made to the procedure find_procedure_length is order to
find the exact length of the procedure to send.
find_procedure_length (@adder,integer(a_tuple^.elements[2].size ));
This procedure will find the length of the procedure and
assign it to the appropriate element size. This is the end of the
tuple formation so the tuple is sent to the master using the set
element eval to instruct the master to treat this tuple as an eval
tuple.
send_tuple ( a_tuple, eval );
RDP (); and INP ();
The RDP and INP instructions are a little different than
the other instructions. The name of the tuple and elements are
formed the same as the RD and IN instruction but after that we have
a choice of operations. Remember that the form of the INP and RDP
instructions is to assign them to a boolean variable such as the
INP instruction
ok := inp ( 'stuff' );
This instruction would be translated as
begin
make_tuple(5,'s','t','u','f','f',' ',' ',' ',' ',' ',' ',' ',' ','
',' ',' ', nil, 0, null, nil, 0, null,
nil, 0, null,
nil, 0, null,
nil, 0, null,
nil, 0, null
);
send_tuple ( a_tuple, inp );
get_tuple ( pkt, plen );
if mem[seg(pkt^):ofs(pkt^)+17] = byte ( tuple_commands ( none ))
then ok := false else
begin
ok := true;
convert_to_tuple_made ( pkt, a_tuple );
end;
end;
We are concerned with the code after a tuple is received
from the master. If the master does not find a match, a null tuple
is returned to the requestor, otherwise, the matching tuple is
returned.
This code determines if the tuple received was null or not.
if mem[seg(pkt^):ofs(pkt^)+17] = byte ( tuple_commands ( none ))
then ok := false else
begin
ok := true;
convert_to_tuple_made ( pkt, a_tuple );
end;
A specific location inside of all tuples indicates the
operation the master perform on the tuple. If this case, if the
operation was NONE, the tuple is null and the boolean variable must
be assigned the value FALSE. We must also make sure that no
formals are given values in the null tuple.
If the tuple is not null, the boolean variable is set to
TRUE and the tuple is converted. After which all memory allocated
is released.
The RDP and INP instructions have the additional boolean
variable to worry about during compile time. If this variable is
not declared, Turbo Pascal will flag it.
OUT ();
The OUT instruction is treated as the RD and IN
instructions except the statements
get_tuple ( pkt, plen );
convert_to_tuple_made ( pkt );
are eliminated since an OUT instruction simply sends the tuple to
the master to be put into tuple space.
BEGIN END;
All tuple commands are enclosed in a BEGIN END; pair. This will
cause an error when tuples are used in the following manner
if a = 1 then
out ( 'num', 1 );
else
out ( 'num', 2 );
this code with generate
if a = 1 then
begin
---
end;
else
begin
---
end;
The problem arises in the Turbo Pascal compiler which requires the
statement preceding the else statement to be free of the ; symbol.
This situation can easily be solved by adding a BEGIN END; pair in
the original code.
if a = 1 then
begin
out ( 'num', 1 );
end
else
out ( 'num', 2 );
Skipped Linda Commands
If your Linda commands are anything other that the
following list and spelled any different, the LCP will not pick
them up.
in (); out (); rd (); inp (); rdp (); eval ();
There must be a space between the Linda word and the (
character. If there isn't, LCP will skip the command. This will be
fixed in a future release.
Problems
Any problems encountered with the Linda Conversion Program should
be directed to:
Parallel Computer Solutions
2112 Hancock Street #205
Laramie, Wyoming 82070
EMAIL gradecki@master.uwyo.edu